package com.zy.chapter6


/**
 * @author: zhaoyi
 * @create: 2020-06-10 00:41
 * @description: ${description}
 **/
object EnumTest {

  import com.zy.chapter6.EnumDataSource._

  def loadData(sourceType: EnumDataSource) {
    sourceType match {
      case KAFKA => println("sourceType is " + sourceType)
      case HDFS => println("sourceType is " + sourceType)
      case ES => println("sourceType is " + sourceType)
      case MYSQL => println("sourceType is " + sourceType)
      case _ => println("Unknown type")
    }
  }

  def main(args: Array[String]): Unit = {
    loadData(EnumDataSource.ES)
    loadData(EnumDataSource.MYSQL)

    for (elem <- EnumDataSource.values) {
      println(elem)
      println(elem.id)
    }

    println(EnumDataSource(0))
    println(EnumDataSource.withName("mysql"))
    println(EnumDataSource.withName("HDFS"))
    println(EnumDataSource.withName("MYSQL"))//NoSuchElementException: No value found for 'MYSQL'



  }

}
